<script type="text/javascript" src="<?php echo base_url(); ?>assets/js/md5-min.js"></script>
<form action="<?php echo base_url().index_page(); ?>/adminpage/process/" method="post" name="adminForm" id="adminForm" autocomplete="off" enctype="multipart/form-data">
<div id="register">
 <fieldset style="border:none">
 <div class="error_validate" id="error_message" style="color:#FF0000"></div><?php echo highlight_phrase($this->session->flashdata('message'), $this->session->flashdata('message'), '<span style="color:#FF0000">', '</span>');  ?>
 <div>
    <label for="cusername"><?php echo $this->lang->line('username'); ?></label>
    <input id="cusername" name="username" type="text" size="30" maxlength="30" value="<?php echo $_SESSION['username'] ?>" disabled="disabled"/>
</div>
<div>
    <label for="currentpassword"><?php echo $this->lang->line('currentpassword'); ?></label>
    <input  id="currentpassword" name="currentpassword" type="password" size="30" maxlength="20" onblur="javascript: checkpass()"/> <span id="pass" style="padding-left:5px;"></span>

</div>
<div>
    <label for="newpassword"><?php echo $this->lang->line('newpassword'); ?></label>
    <input id="newpassword" name="newpassword" type="password" size="30" maxlength="20"/>&nbsp;<?php echo $this->lang->line('f_password_length'); ?>
</div>
<div>
    <label for="renewpassword"><?php echo $this->lang->line('renewpassword'); ?></label>
    <input id="renewpassword" name="renewpassword" type="password" size="30" maxlength="20"/>
</div>

		<input type="hidden" name="id" value="<?php echo $_SESSION['user_ID'] ?>" />
		<input type="hidden" name="component" value="com_users" />
		<input type="hidden" name="option" value="changepassword" />
		<input type="hidden" name="myurl" value="<?php echo base_url().$this->uri->uri_string(); ?>" />
		<input type="hidden" name="task" value="" />
 </fieldset>
</div>
</form>
<div align="center">
<div class="toolbar">
<table width="100px" border="0" align="center" cellpadding="5">
  <tr>
    <td align="center"><a onclick="javascript: submitbutton('save')" href="#"><span class="icon-32-save" title="<?php echo $this->lang->line('save'); ?>"> </span><?php echo $this->lang->line('save'); ?></a></td>
    <td align="center"><a onclick="javascript: submitbutton('cancel')" href="#"><span class="icon-32-cancel" title="<?php echo $this->lang->line('cancel'); ?>"> </span><?php echo $this->lang->line('cancel'); ?></a></td>
  </tr>
</table>
</div>
</div>
<script>
function checkvalidate() 
{
	result=0;
	curr_pass=document.getElementById("currentpassword").value;
	new_pass=document.getElementById("newpassword").value;
	renew_pass=document.getElementById("renewpassword").value;
	if (curr_pass=="" || new_pass=="" || renew_pass=="")
	{
		document.getElementById("error_message").innerHTML="<?php echo $this->lang->line('f_all_field'); ?>";
	}
	else if (new_pass.length<8)
	{
		document.getElementById("error_message").innerHTML="<?php echo $this->lang->line('f_password_length'); ?>";
	}
	else if (new_pass!=renew_pass)
	{
		document.getElementById("error_message").innerHTML="<?php echo $this->lang->line('f_confirm_password'); ?>";
	}
	else if (document.getElementById("correctpass").value==0)
	{
		result=0;
	}
	else
	{
		result=1;
	}
	return result;
}
function checkpass()
{
	//alert(hex_md5(document.getElementById('currentpassword').value));
	if(document.getElementById("currentpassword").value!='')
	{
		$.ajax(
		{	
			type: "POST",
			url: "<?php echo base_url().index_page(); ?>/admin/checkpass/"+ hex_md5(document.getElementById("currentpassword").value),
			success: function(result)
			{
				$("#pass").html(result);
			}
		});
	}
}

</script>